/* Turska Framework/UI library (Turs2)
 * Copyright 2003-2009 Jetro Lauha
 * All rights reserved.
 * Web: http://iki.fi/jetro/turska/
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of EITHER:
 *   (1) The GNU Lesser General Public License as published by the Free
 *       Software Foundation; either version 2.1 of the License, or (at
 *       your option) any later version. The text of the GNU Lesser
 *       General Public License is included with this library in the
 *       file LICENSE-LGPL.txt.
 *   (2) The BSD-style license that is included with this library in
 *       the file LICENSE-BSD.txt.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the files
 * LICENSE-LGPL.txt and LICENSE-BSD.txt for more details.
 *
 * $Id: T2IMGUIImageButtonStyle.h 131 2009-06-05 05:58:05Z jlauha $
 * $Revision: 131 $
 */

#ifndef T2IMGUIIMAGEBUTTONSTYLE_H_INCL
#define T2IMGUIIMAGEBUTTONSTYLE_H_INCL


namespace turska
{
    //! Image button with fixed extents defined by the image size.
    /*! The width and height are ignored when there's an image to use.
     */
    class IMGUIImageButtonStyle : public IMGUIButtonStyle
    {
    public:
        IMGUIImageButtonStyle(Font *font, Image *imageUp, Image *imageHot,
                              Image *imageActive, Image *imageHotDown);

        virtual bool isKeyFocusAllowed() { return mKeyFocusAllowed; }

        // From IMGUIButtonStyle:

        virtual bool activatesFromUpEvent() { return mActivateFromUpEvent; }

        virtual bool isInside(const IMGUI &imgui, REAL x, REAL y,
                              const Rectangle &area,
                              const C8 *text, Image *image);

        virtual Rectangle render(const IMGUI &imgui, I32 widgetState,
                                 REAL x, REAL y, REAL width, REAL height,
                                 const C8 *text, Image *image);

        // Local

        void setScale(REAL scale) { mScale = scale; }
        void setButtonColor(const Color &color) { mButtonColor = color; }
        void setImageColor(const Color &color) { mImageColor = color; }
        void setTextColor(const Color &color) { mTextColor = color; }
        void setFont(Font *font) { mFont = font; }

        void setShadowMultiplierColor(const Color &color) { mShadowMultiplierColor = color; }
        void setShadowEnabled(bool enabled) { mShadowEnabled = enabled; }
        void setTextOffset(REAL xOffset, REAL yOffset) { mTextXOffset = xOffset; mTextYOffset = yOffset; }
        void setImageOffset(REAL xOffset, REAL yOffset) { mImageXOffset = xOffset; mImageYOffset = yOffset; }
        void setShadowOffset(REAL xOffset, REAL yOffset) { mShadowXOffset = xOffset; mShadowYOffset = yOffset; }
        void setButtonDownTextOffset(REAL xOffset, REAL yOffset) { mButtonDownTextXOffset = xOffset; mButtonDownTextYOffset = yOffset; }
        void setButtonDownImageOffset(REAL xOffset, REAL yOffset) { mButtonDownImageXOffset = xOffset; mButtonDownImageYOffset = yOffset; }
        void setTextFlags(UI32 flags) { mTextFlags = flags; }
        void setImageFlags(UI32 flags) { mImageFlags = flags; }
        void setTextDrawMode(IMAGE_DRAW_MODE drawMode) { mTextDrawMode = drawMode; }
        void setImageDrawMode(IMAGE_DRAW_MODE drawMode) { mImageDrawMode = drawMode; }
        void setTextScale(REAL textScale) { mTextScale = textScale; }

        void setKeyFocusAllowed(bool allowed) { mKeyFocusAllowed = allowed; }

        void setActivateFromUpEvent(bool fromUpEvent) { mActivateFromUpEvent = fromUpEvent; }

        REAL getWidth();
        REAL getHeight();

    protected:
        REAL mScale;
        Color mButtonColor;
        Color mImageColor, mTextColor;
        Color mShadowMultiplierColor;
        Image *mImages[IMGUI_WS_COUNT];
        UI32 mImageWidth, mImageHeight;
        Font *mFont;
        bool mShadowEnabled;
        REAL mTextXOffset, mTextYOffset;
        REAL mImageXOffset, mImageYOffset;
        REAL mShadowXOffset, mShadowYOffset;
        REAL mButtonDownTextXOffset, mButtonDownTextYOffset;
        REAL mButtonDownImageXOffset, mButtonDownImageYOffset;
        UI32 mTextFlags, mImageFlags;
        IMAGE_DRAW_MODE mTextDrawMode, mImageDrawMode;
        REAL mTextScale;
        bool mKeyFocusAllowed, mActivateFromUpEvent;
    };

} // namespace turska


#endif // !T2IMGUIIMAGEBUTTONSTYLE_H_INCL
